package com.parking.platform.controller;


import com.parking.common.core.model.Result;
import com.parking.common.core.util.JwtUtil;
import com.parking.common.web.aop.Permission;
import com.parking.common.web.util.RedisUtil;
import com.parking.platform.dao.PlatformAccountRoleMapper;
import com.parking.platform.form.UpAccountRoleForm;
import com.parking.platform.service.PlatformAccountRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 香菜狗带
 * @since 2023年11月28日
 */
@RestController
@RequestMapping("/platformAccountRole")
@Api(tags = "平台账号角色接口")
public class PlatformAccountRoleController {

    @Resource
    private PlatformAccountRoleService platformAccountRoleService;
    @Resource
    private RedisUtil redisUtil;
    /**
     * 修改平台管理员角色
     * platformId：平台管理员ID
     * platformRoleId：角色ID
     * authorization:令牌
     * */
    @PostMapping("/modifyAccountRoleById.platform")
    @Permission(resources = {"/modifyAccountRoleById.platform"})
    @ApiOperation("修改平台管理员角色")
    @Transactional
    public Result modifyAccountRoleById(@RequestBody UpAccountRoleForm form, @RequestHeader("authorization") String authorization)throws Exception{
        System.out.println(form+"参数");
        String refreshToken = redisUtil.get(authorization);
        Integer platformId = JwtUtil.getPlatformId(refreshToken);
        platformAccountRoleService.modifyAccountRoleById(platformId,form);
        return Result.getResult().setCode(200).setMessage("修改平台管理员角色成功");
    }



}

